/**
 * Created by asus on 2017/4/23.
 */

public class User {
    private int Age;
    public void setAge(int age) throws Exception{
        if (age < 0){
            Exception e = new Exception("年龄不能为负数");
            throw e;
        }
        this.Age = age;
    }
    public static void main (String [] args){
        User user = new User();
        try{
            user.setAge(-20);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}